tongfusoft.userAdd = function() {
}

tongfusoft.userAdd.prototype = {
	dataSubmit : function() {

		$.validator.setDefaults({
			submitHandler : function() {
				var initData = common.getData("addUser-from");
				var url = 'manager/user/add';
				common.ajaxSubmitOnSuccess(initData, url, function(data) {
					if (data.state == 'success') {
						toastr["success"]('添加成功!');
						var userId = data.data.userId;
						window.location.href = common.getContextPath("manager/user/editPage/?userId="+ userId + "&&opr=edit");
					} else if (data.code == 'repeat_error') {

						toastr["error"]('用户名不能重复!');
					} else {
						toastr["error"]('保存失败!');
					}
				})
			}
		});
		$("#addUser-from").validate();

		$("#submitBtn").click(function() {
			$("#addUser-from").submit();
		})

		$("#userListPage").click(function() {
			window.location.href = common.getContextPath('manager/user/listPage');
		})
	},
}

$(function() {

	var user = new tongfusoft.userAdd();
	user.dataSubmit();
})